﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.ServiceModel;
using System.IO;

namespace SPVisualDev.Services
{
    [ServiceContract(Namespace = "urn:SPVisualDevWinSvc#MainService")]
    public interface IMainService
    {
        [OperationContract]
        string GetServiceVersion();

        [OperationContract]
        bool TestConnectivity();

        [OperationContract]
        void InstallFeature(string FeatureName, bool Force);

        [OperationContract]
        void UninstallFeature(string FeatureName, bool Force);

        [OperationContract]
        void ActivateFeature(string FeatureName, string Url, bool Force);

        [OperationContract]
        void DeactivateFeature(string FeatureName, string Url, bool Force);

        [OperationContract]
        void DeployWSP(string WSPFileName, string TempWSPFileName, string[] WebApplicationURLs, bool bGAC);
        
        [OperationContract]
        void RecycleIISAppPools(string Url);

        [OperationContract]
        int GetWebApplicationPID(string Url);

        [OperationContract]
        int GetServicePID();

        /// <summary>
        /// Installs binary
        /// </summary>
        /// <param name="AssemblyFileName"></param>
        /// <param name="TransferedFile"></param>
        /// <param name="Gac">Register in GAC</param>
        /// <param name="Operation">0 = Install, 1 = Uninstall</param>
        /// <param name="AppBinURLs"></param>
        [OperationContract]
        void BinInstall(string AssemblyFileName, string AssemblyTempFileName, string ParentAssemblyFullName, bool Gac, int Operation, string[] AppBinURLs);

        [OperationContract]
        string UploadTempFile(Stream FileToUpload);

        [OperationContract]
        string GetContentTypeGroups(string Url);

        [OperationContract]
        string GetContentTypesByGroup(string Url, string Group);

        [OperationContract]
        string GetContentTypesData(string Url, string Name);

        [OperationContract]
        string GetAllBuiltInContentTypes();


        [OperationContract]
        [ServiceKnownType(typeof(ExFarm))]
        [ServiceKnownType(typeof(ExWebApplication))]
        [ServiceKnownType(typeof(ExSite))]
        [ServiceKnownType(typeof(ExWeb))]
        [ServiceKnownType(typeof(ExList))]
        [ServiceKnownType(typeof(ExFeaturesCollection))]
        [ServiceKnownType(typeof(ExFeature))]
        [ServiceKnownType(typeof(ExContentType))]
        [ServiceKnownType(typeof(ExField))]
        [ServiceKnownType(typeof(ExFarmSolution))]
        [ServiceKnownType(typeof(ExEventReceiver))]
        List<IExplorerObjectContainer> GetChildren(IExplorerObjectContainer Parent, string SubGroup);

        [OperationContract]
        [ServiceKnownType(typeof(ExFarm))]
        [ServiceKnownType(typeof(ExWebApplication))]
        [ServiceKnownType(typeof(ExSite))]
        [ServiceKnownType(typeof(ExWeb))]
        [ServiceKnownType(typeof(ExList))]
        [ServiceKnownType(typeof(ExFeaturesCollection))]
        [ServiceKnownType(typeof(ExFeature))]
        [ServiceKnownType(typeof(ExContentType))]
        [ServiceKnownType(typeof(ExField))]
        [ServiceKnownType(typeof(ExFarmSolution))]
        [ServiceKnownType(typeof(ExEventReceiver))]
        List<string> GetSubGroups(IExplorerObjectContainer Parent);

        [OperationContract]
        [ServiceKnownType(typeof(ExFarm))]
        [ServiceKnownType(typeof(ExWebApplication))]
        [ServiceKnownType(typeof(ExSite))]
        [ServiceKnownType(typeof(ExWeb))]
        [ServiceKnownType(typeof(ExList))]
        [ServiceKnownType(typeof(ExFeaturesCollection))]
        [ServiceKnownType(typeof(ExFeature))]
        [ServiceKnownType(typeof(ExContentType))]
        [ServiceKnownType(typeof(ExField))]
        [ServiceKnownType(typeof(ExFarmSolution))]
        [ServiceKnownType(typeof(ExEventReceiver))]
        Dictionary<string, string> GetProperties(IExplorerObjectContainer Parent);

        [OperationContract]
        void DeletePathIn12Hive(string ProjectRelativePath, int PathKind);

        [OperationContract]
        void PutFile(byte[] File, string DestinationPath);

        [OperationContract]
        void CreateDirectoryIn12Hive(string ProjectRelativePath);

        [OperationContract]
        bool PutFileIn12Hive(string TempFileName, DateTime[] TimeInfo, string ProjectRelativePath, bool OverWriteIfOlder, bool ForceOverwrite);

        [OperationContract]
        bool FileExistsIn12Hive(string ProjectRelativePath, int PathKind);

        [OperationContract]
        Stream GetFileIn12Hive(string _12HiveRelativePath);

        [OperationContract]
        string[] EnumerateFilesIn12HiveDirectory(string _12HiveRelativePath);
    }
}
